home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Heap
/
HeapLink.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
986b
|
59 lines
// HeapLink.cp
#define HeapLink_cp
#ifndef HeapLink_h
#include "HeapLink.h"
#endif
#ifndef Heap_h
#include "Heap.h"
#endif
#ifndef Swap_h
#include "Swap.h"
#endif
#ifndef Heap_h
#include "Heap.h"
#endif
template < class Element >
HeapLink<Element>::HeapLink( Element *e )
: heap( 0 ),
body( e ),
path( 0 )
{
children[0] = 0;
children[1] = 0;
}
template < class Element >
HeapLink<Element>::~HeapLink()
{
if ( heap != 0 )
heap->Remove( *this );
Assert( heap == 0 );
}
template < class Element >
void HeapLink<Element>::SwapWith( LinkType& r )
{
Assert( heap == r.heap );
Swap( path, r.path );
Swap( children[0], r.children[0] );
Swap( children[1], r.children[1] );
}
template < class Element >
bool HeapLink<Element>::operator<=( const LinkType& r ) const
{
Assert( heap == r.heap );
Assert( heap != 0 );
Comparator below( heap->Below() );
Assert( below != 0 );
Assert( !Null() );
Assert( !r.Null() );
return (body->*below)(*r.body);
}